package cn.ahaiahaixx.dp.abstractFactory;

import java.lang.reflect.Method;

public class OtherDemo {
  public static void main(String[] args) {
    Factory factory = FactoryManager.getFactory(Microsoft.class);
    System.out.println(factory.getClass());
    Toy toy = factory.makeToy();
    System.out.println(toy.getClass());
    toy.play();
    // FactoryManager.getFactory(String.class);

    factory = FactoryManager.getFactory(Sony.class);
    System.out.println(factory.getClass());
    toy = factory.makeToy();
    System.out.println(toy.getClass());
    toy.play();
    
    //通过反射获取对象定义的方法
    System.out.println("=====================================");
    Method[] methods=factory.getClass().getDeclaredMethods();
    for (Method method:methods) {
      System.out.println(method);
    }
  }
}
